package com.xc.h05.service.weichen.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xc.h05.entity.HeartMarkQ;
import com.xc.h05.entity.Heartmark;
import com.xc.h05.mapper.HeartMarkQMapper;
import com.xc.h05.mapper.HeartmarkMapper;
import com.xc.h05.service.weichen.HeartMarkQService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HeartMarkQServiceImpl implements HeartMarkQService{
    @Autowired
    private HeartMarkQMapper heartMarkQMapper;
    @Autowired
    private HeartmarkMapper heartmarkMapper;
    @Override
    public PageInfo<HeartMarkQ> findByPage(int pageNum, int pageSize, HeartMarkQ heartMarkQ) {
        PageHelper.startPage(pageNum,pageSize);
        List<HeartMarkQ> list = heartMarkQMapper.findByPage(heartMarkQ);
        for (HeartMarkQ hmq : list) {
            Heartmark heartmark = heartmarkMapper.findById(hmq.getTestId());
            hmq.setHeartmark(heartmark);
        }
        PageInfo<HeartMarkQ> pageInfo = new PageInfo<>(list);
        return pageInfo;

    }

    @Override
    public int add(HeartMarkQ heartMarkQ) {
        int add = heartMarkQMapper.add(heartMarkQ);
        return add;
    }

    @Override
    public int delete(int id) {
        int delete = heartMarkQMapper.delete(id);
        return delete;
    }

    @Override
    public int deletes(List list) {
        int deletes = heartMarkQMapper.deletes(list);
        return deletes;
    }

    @Override
    public int update(HeartMarkQ heartMarkQ) {
        int update = heartMarkQMapper.update(heartMarkQ);
        return update;
    }

    @Override
    public List<HeartMarkQ> findByTestId(int testId) {
        List<HeartMarkQ> list = heartMarkQMapper.findByTestId(testId);
        return list;
    }
}
